package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {

    //总用户数量
    @Select("select sum(num_registered) from tb_analysis_by_day")
    Long findUserTotalCount();

    //过去指定天数活跃用户数量
    @Select("select sum(num_active) from tb_analysis_by_day where record_date BETWEEN #{start} and #{end}")
    Long findActiveUserCountInPeriod(@Param("start") String start, @Param("end") String end);

    //查询指定日期的所有数量
    @Select("SELECT * FROM tb_analysis_by_day WHERE record_date = #{recordDate}")
    AnalysisByDay findByRecordDate(String recordDate);

    //根据起始和结束时间查询
    @Select("SELECT * FROM tb_analysis_by_day WHERE record_date BETWEEN #{start} AND #{end}")
    List<AnalysisByDay> selectByTime(@Param("start") String start,@Param("end") String end);
}